package com.urea.web.controller.urea;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.urea.common.annotation.Log;
import com.urea.common.core.controller.BaseController;
import com.urea.common.core.domain.AjaxResult;
import com.urea.common.enums.BusinessType;
import com.urea.system.domain.CustomerAccountDetail;
import com.urea.system.service.ICustomerAccountDetailService;
import com.urea.common.utils.poi.ExcelUtil;
import com.urea.common.core.page.TableDataInfo;

/**
 * 账户流水Controller
 * 
 * @author liuzd
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/customer/account/detail")
public class CustomerAccountDetailController extends BaseController
{
    @Autowired
    private ICustomerAccountDetailService customerAccountDetailService;

    /**
     * 查询账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerAccountDetail customerAccountDetail)
    {
        startPage();
        List<CustomerAccountDetail> list = customerAccountDetailService.selectCustomerAccountDetailList(customerAccountDetail);
        return getDataTable(list);
    }

    /**
     * 导出账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:export')")
    @Log(title = "账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerAccountDetail customerAccountDetail)
    {
        List<CustomerAccountDetail> list = customerAccountDetailService.selectCustomerAccountDetailList(customerAccountDetail);
        ExcelUtil<CustomerAccountDetail> util = new ExcelUtil<CustomerAccountDetail>(CustomerAccountDetail.class);
        util.exportExcel(response, list, "账户流水数据");
    }

    /**
     * 获取账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(customerAccountDetailService.selectCustomerAccountDetailById(id));
    }

    /**
     * 新增账户流水
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:add')")
    @Log(title = "账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerAccountDetail customerAccountDetail)
    {
        return toAjax(customerAccountDetailService.insertCustomerAccountDetail(customerAccountDetail));
    }

    /**
     * 修改账户流水
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:edit')")
    @Log(title = "账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerAccountDetail customerAccountDetail)
    {
        return toAjax(customerAccountDetailService.updateCustomerAccountDetail(customerAccountDetail));
    }

    /**
     * 删除账户流水
     */
    @PreAuthorize("@ss.hasPermi('customer:detail:remove')")
    @Log(title = "账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerAccountDetailService.deleteCustomerAccountDetailByIds(ids));
    }
}
